var gulp = require('gulp');
var mocha = require('gulp-mocha');
var env = require('gulp-env');


gulp.task('set-dev-node-env', function () {
    return process.env.NODE_ENV = 'development';
});


gulp.task('set-prod-node-env', function () {
    return process.env.NODE_ENV = 'production';
});

gulp.task('set-test-node-env', function (cb) {
    process.env.NODE_ENV = 'test';
    process.env.NODE_CONFIG_DIR = '../../config'
    require('./../../init/properties.js');
    require('should');
    require('./../../env');
    cb();
});

gulp.task("login", ['set-test-node-env'], function () {

    return gulp.src([
        './test/routes/login.test.js'
    ]).pipe(mocha()).on('error', function (err) {
        process.exit(1);
    }).on('end', function () {
        process.exit(0);
    });
});

gulp.task("activityAdd", ['set-test-node-env'], function () {

    return gulp.src([
        './test/routes/activity.add.test.js'
    ]).pipe(mocha()).on('error', function (err) {
        process.exit(1);
    }).on('end', function () {
        process.exit(0);
    });
});


gulp.task("signUp", ['set-test-node-env'], function () {

    return gulp.src([
        './test/routes/signUp.test.js'
    ]).pipe(mocha()).on('error', function (err) {
        process.exit(1);
    }).on('end', function () {
        process.exit(0);
    });
});

gulp.task("user", ['set-test-node-env'], function () {

    return gulp.src([
        './test/routes/user.add.test.js'
    ]).pipe(mocha()).on('error', function (err) {
        process.exit(1);
    }).on('end', function () {
        process.exit(0);
    });
});

gulp.task("videoAdd", ['set-test-node-env'], function () {

    return gulp.src([
        './test/routes/video.add.test.js'
    ]).pipe(mocha()).on('error', function (err) {
        process.exit(1);
    }).on('end', function () {
        process.exit(0);
    });
});

gulp.task("videoDelete", ['set-test-node-env'], function () {

    return gulp.src([
        './test/routes/video.delete.test.js'
    ]).pipe(mocha()).on('error', function (err) {
        process.exit(1);
    }).on('end', function () {
        process.exit(0);
    });
});

gulp.task("videoUpdate", ['set-test-node-env'], function () {

    return gulp.src([
        './test/routes/video.update.test.js'
    ]).pipe(mocha()).on('error', function (err) {
        process.exit(1);
    }).on('end', function () {
        process.exit(0);
    });
});

gulp.task("videoList", ['set-test-node-env'], function () {

    return gulp.src([
        './test/routes/video.list.test.js'
    ]).pipe(mocha()).on('error', function (err) {
        process.exit(1);
    }).on('end', function () {
        process.exit(0);
    });
});